#include "trace/include/logger.h"

void BoostLog::initBoostLog(bool enable)
{
    if(enable)
    {
        try
        {
            namespace expr = boost::log::expressions;
            boost::log::add_file_log
            (
                boost::log::keywords::auto_flush = true,
                boost::log::keywords::file_name = "/tmp/Vsomeip/Vsomeip_%Y-%m-%d-%H-%M-%S.log",
                boost::log::keywords::rotation_size = 10 * 1024 * 1024,
                boost::log::keywords::time_based_rotation = boost::log::sinks::file::rotation_at_time_point(0, 0, 0),
                boost::log::keywords::format = //"[%TimeStamp%]:[%format%]: %Message%"
                (
                    expr::stream
                    << expr::format_date_time<boost::posix_time::ptime>("TimeStamp", "%Y-%m-%d-%H:%M:%S.%f")
                    << ": <" << boost::log::trivial::severity
                    << "> "
                    << expr::smessage
                )
            );
            boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::debug);
            boost::log::add_common_attributes();//!!!
            }
        catch(const std::exception& e)
        {
            std::cerr << e.what() << '\n';
        }
        
        
    }
}
